home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / game / shoot / ADescentSrc.lha / descent / main / kmatrix.c < prev    next >
C/C++ Source or Header  |  1998-03-03  |  8KB  |  330 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: /usr/CVS/descent/main/kmatrix.c,v $
  15.  * $Revision: 1.1.1.1 $
  16.  * $Author: nobody $
  17.  * $Date: 1998/03/03 15:12:23 $
  18.  * 
  19.  * Kill matrix displayed at end of level.
  20.  * 
  21.  * $Log: kmatrix.c,v $
  22.  * Revision 1.1.1.1  1998/03/03 15:12:23  nobody
  23.  * reimport after crash from backup
  24.  *
  25.  * Revision 1.1.1.1  1998/02/13  20:20:57  hfrieden
  26.  * Initial Import
  27.  *
  28.  * Revision 2.3  1995/05/02  17:01:22  john
  29.  * Fixed bug with kill list not showing up in VFX mode.
  30.  * 
  31.  * Revision 2.2  1995/03/21  14:38:20  john
  32.  * Ifdef'd out the NETWORK code.
  33.  * 
  34.  * Revision 2.1  1995/03/06  15:22:54  john
  35.  * New screen techniques.
  36.  * 
  37.  * Revision 2.0  1995/02/27  11:25:56  john
  38.  * New version 2.0, which has no anonymous unions, builds with
  39.  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  40.  * 
  41.  * Revision 1.19  1995/02/15  14:47:23  john
  42.  * Added code to keep track of kills during endlevel.
  43.  * 
  44.  * Revision 1.18  1995/02/08  11:00:06  rob
  45.  * Moved string to localized file
  46.  * 
  47.  * Revision 1.17  1995/02/01  23:45:55  rob
  48.  * Fixed string.
  49.  * 
  50.  * Revision 1.16  1995/01/30  21:47:11  rob
  51.  * Added a line of instructions.
  52.  * 
  53.  * Revision 1.15  1995/01/20  16:58:43  rob
  54.  * careless careless careless... 
  55.  * 
  56.  * 
  57.  * Revision 1.14  1995/01/20  13:43:48  rob
  58.  * Longer time to view.
  59.  * 
  60.  * Revision 1.13  1995/01/20  13:42:34  rob
  61.  * Fixed sorting bug.
  62.  * 
  63.  * Revision 1.12  1995/01/19  17:35:21  rob
  64.  * Fixed coloration of player names in team mode.
  65.  * 
  66.  * Revision 1.11  1995/01/16  21:26:15  rob
  67.  * Fixed it!!
  68.  * 
  69.  * Revision 1.10  1995/01/16  18:55:41  rob
  70.  * Added include of network.h
  71.  * 
  72.  * Revision 1.9  1995/01/16  18:22:35  rob
  73.  * Fixed problem with signs.
  74.  * 
  75.  * Revision 1.8  1995/01/12  16:07:51  rob
  76.  * ADded sorting before display.
  77.  * 
  78.  * Revision 1.7  1995/01/04  08:46:53  rob
  79.  * JOHN CHECKED IN FOR ROB !!!
  80.  * 
  81.  * Revision 1.6  1994/12/09  20:17:20  yuan
  82.  * Touched up
  83.  * 
  84.  * Revision 1.5  1994/12/09  19:46:35  yuan
  85.  * Localized the sucker.
  86.  * 
  87.  * Revision 1.4  1994/12/09  19:24:58  rob
  88.  * Yuan's fix to the centering.
  89.  * 
  90.  * Revision 1.3  1994/12/09  19:02:37  yuan
  91.  * Cleaned up a bit.
  92.  * 
  93.  * Revision 1.2  1994/12/09  16:19:46  yuan
  94.  * kill matrix stuff.
  95.  * 
  96.  * Revision 1.1  1994/12/09  15:08:58  yuan
  97.  * Initial revision
  98.  * 
  99.  * 
  100.  */
  101.  
  102.  
  103. #pragma off (unreferenced)
  104. static char rcsid[] = "$Id: kmatrix.c,v 1.1.1.1 1998/03/03 15:12:23 nobody Exp $";
  105. #pragma on (unreferenced)
  106.  
  107. #include <stdio.h>
  108. #include <stdlib.h>
  109. #include <string.h>
  110. #include <ctype.h>
  111. #include <stdarg.h>
  112.  
  113. #include "error.h"
  114. #include "types.h"
  115. #include "gr.h"
  116. #include "mono.h"
  117. #include "key.h"
  118. #include "palette.h"
  119. #include "game.h"
  120. #include "gamefont.h"
  121. #include "mem.h"
  122. #include "newmenu.h"
  123. #include "menu.h"
  124. #include "player.h"
  125. #include "screens.h"
  126. #include "gamefont.h"
  127. #include "mouse.h"
  128. #include "joy.h"
  129. #include "timer.h"
  130. #include "text.h"
  131. #include "multi.h"
  132. #include "kmatrix.h"
  133. #include "gauges.h"
  134. #include "pcx.h"
  135. #include "network.h"
  136.  
  137. #define CENTERING_OFFSET(x) ((300 - (70 + (x)*25 ))/2)
  138.  
  139. int kmatrix_kills_changed = 0;
  140.  
  141. void kmatrix_draw_item( int  i, int *sorted )
  142. {
  143.     int j, x, y;
  144.  
  145.     y = 50+i*9;
  146.  
  147.     // Print player name.
  148.  
  149.     gr_printf( CENTERING_OFFSET(N_players), y, "%s", Players[sorted[i]].callsign );
  150.  
  151.     for (j=0; j<N_players; j++) {
  152.  
  153.         x = 70 + CENTERING_OFFSET(N_players) + j*25;
  154.  
  155.         if (sorted[i]==sorted[j]) {
  156.             if (kill_matrix[sorted[i]][sorted[j]] == 0) {
  157.                 gr_set_fontcolor( BM_XRGB(10,10,10),-1 );
  158.                 gr_printf( x, y, "%d", kill_matrix[sorted[i]][sorted[j]] );
  159.             } else {
  160.                 gr_set_fontcolor( BM_XRGB(25,25,25),-1 );
  161.                 gr_printf( x, y, "-%d", kill_matrix[sorted[i]][sorted[j]] );
  162.             }
  163.         } else {
  164.             if (kill_matrix[sorted[i]][sorted[j]] <= 0) {
  165.                 gr_set_fontcolor( BM_XRGB(10,10,10),-1 );
  166.                 gr_printf( x, y, "%d", kill_matrix[sorted[i]][sorted[j]] );
  167.             } else {
  168.                 gr_set_fontcolor( BM_XRGB(25,25,25),-1 );
  169.                 gr_printf( x, y, "%d", kill_matrix[sorted[i]][sorted[j]] );
  170.             }
  171.         }
  172.  
  173.     }
  174.     
  175.     x = 70 + CENTERING_OFFSET(N_players) + N_players*25;
  176.     gr_set_fontcolor( BM_XRGB(25,25,25),-1 );
  177.     gr_printf( x ,y,"%4d",Players[sorted[i]].net_kills_total);
  178. }
  179.  
  180. void kmatrix_draw_names(int *sorted)
  181. {
  182.     int j, x;
  183.     
  184.     int color;
  185.  
  186.     for (j=0; j<N_players; j++) {
  187.         if (Game_mode & GM_TEAM)
  188.             color = get_team(sorted[j]);
  189.         else
  190.             color = sorted[j];
  191.  
  192.         x = 70 + CENTERING_OFFSET(N_players) + j*25;
  193.         gr_set_fontcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
  194.         gr_printf( x, 40, "%c", Players[sorted[j]].callsign[0] );
  195.     }
  196.  
  197.     x = 70 + CENTERING_OFFSET(N_players) + N_players*25;
  198.     gr_set_fontcolor( BM_XRGB(31,31,31),-1 );
  199.     gr_printf( x, 40, TXT_KILLS);
  200.         
  201. }
  202.  
  203.  
  204. void kmatrix_draw_deaths(int *sorted)
  205. {
  206.     int j, x, y;
  207.     
  208.     y = 55 + N_players * 9;
  209.  
  210. //    gr_set_fontcolor(gr_getcolor(player_rgb[j].r,player_rgb[j].g,player_rgb[j].b),-1 );
  211.     gr_set_fontcolor( BM_XRGB(31,31,31),-1 );
  212.  
  213.     x = CENTERING_OFFSET(N_players);
  214.     gr_printf( x, y, TXT_DEATHS );
  215.  
  216.     for (j=0; j<N_players; j++) {
  217.         x = 70 + CENTERING_OFFSET(N_players) + j*25;
  218.         gr_printf( x, y, "%d", Players[sorted[j]].net_killed_total );
  219.     }
  220.  
  221.     y = 55 + 72 + 12;
  222.     x = 35;
  223.  
  224.     {
  225.         int sw, sh, aw;
  226.         gr_get_string_size(TXT_PRESS_ANY_KEY2, &sw, &sh, &aw);    
  227.         gr_printf( 160-(sw/2), y, TXT_PRESS_ANY_KEY2);
  228.     }
  229. }
  230.  
  231. void kmatrix_redraw()
  232. {
  233.     int i, pcx_error, color;
  234.         
  235.     int sorted[MAX_NUM_NET_PLAYERS];
  236.  
  237.     multi_sort_kill_list();
  238.  
  239.     gr_set_current_canvas(NULL);
  240.     
  241.     pcx_error = pcx_read_bitmap("STARS.PCX",&grd_curcanv->cv_bitmap,grd_curcanv->cv_bitmap.bm_type,NULL);
  242.     Assert(pcx_error == PCX_ERROR_NONE);
  243.  
  244.     grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3];
  245.  
  246.     gr_string( 0x8000, 15, TXT_KILL_MATRIX_TITLE    );
  247.  
  248.     grd_curcanv->cv_font = Gamefonts[GFONT_SMALL];
  249.  
  250.     multi_get_kill_list(sorted);
  251.  
  252.     kmatrix_draw_names(sorted);
  253.  
  254.     for (i=0; i<N_players; i++ )        {
  255. //        mprintf((0, "Sorted kill list pos %d = %d.\n", i+1, sorted[i]));
  256.  
  257.         if (Game_mode & GM_TEAM)
  258.             color = get_team(sorted[i]);
  259.         else
  260.             color = sorted[i];
  261.  
  262.         gr_set_fontcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
  263.         kmatrix_draw_item( i, sorted );
  264.     }
  265.  
  266.     kmatrix_draw_deaths(sorted);
  267. }
  268.  
  269. #define MAX_VIEW_TIME    F1_0*60
  270.  
  271.  
  272. void kmatrix_view(int network)
  273. {
  274.     int i, k, done;
  275.     fix entry_time = timer_get_approx_seconds();
  276.     int key;
  277.  
  278.     set_screen_mode( SCREEN_MENU );
  279.  
  280.     kmatrix_redraw();
  281.  
  282.     gr_palette_fade_in( gr_palette,32, 0);
  283.     game_flush_inputs();
  284.  
  285.     done = 0;
  286.  
  287.     while(!done)    {
  288.  
  289.         for (i=0; i<4; i++ )    
  290.             if (joy_get_button_down_cnt(i)>0) done=1;
  291.         for (i=0; i<3; i++ )    
  292.             if (mouse_button_down_count(i)>0) done=1;
  293.  
  294.         k = key_inkey();
  295.         switch( k )    {
  296.             case KEY_ENTER:
  297.             case KEY_SPACEBAR:
  298.             case KEY_ESC:
  299.                 done=1;
  300.                 break;
  301.             case KEY_PRINT_SCREEN:
  302.                 save_screen_shot(0);
  303.                 break;
  304.             case KEY_BACKSP:
  305.                 Int3();
  306.                 break;
  307.             default:
  308.                 break;
  309.         }
  310.         if (timer_get_approx_seconds() > entry_time+MAX_VIEW_TIME)
  311.             done=1;
  312.  
  313.         if (network && (Game_mode & GM_NETWORK))
  314.         {
  315.             kmatrix_kills_changed = 0;
  316.             network_endlevel_poll2(0, NULL, &key, 0);
  317.             if ( kmatrix_kills_changed )    {
  318.                 kmatrix_redraw();
  319.             }
  320.             if (key < -1)
  321.                 done = 1;
  322.         }
  323.     }
  324.  
  325. // Restore background and exit
  326.     gr_palette_fade_out( gr_palette, 32, 0 );
  327.  
  328.     game_flush_inputs();
  329. }
  330.